package es.udc.emarketapp.emarket.model.categoryFacade.actions;


import es.udc.emarketapp.emarket.model.category.dao.SQLCategoryDAO;
import es.udc.emarketapp.emarket.model.category.dao.SQLCategoryDAOFactory;
import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.sql.NonTransactionalPlainAction;


public class  FindCategoryByNameAction implements NonTransactionalPlainAction {

    private String nomCat;

    public FindCategoryByNameAction(String nomCat) {
        this.nomCat = nomCat;
    }


    public Object execute(Connection connection)
        throws InstanceNotFoundException, InternalErrorException {

        SQLCategoryDAO categoryDAO = SQLCategoryDAOFactory.getDAO();

        return categoryDAO.findByName(connection, nomCat);

    }


}
